import React from 'react'

import {WeaLocaleProvider, WeaTools} from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

import './style'
import ContainerModle from '../../common/containerModle'
import ContainerViewExtend from './containerViewExtend'
import SettingProxy from './settingProxy'
import AddExtend from "./addExtend";
import SettingExtend from "./settingExtend";
import MoreContainerView from "./moreContainerView";


export default class More extends React.Component{

    static defaultProps = {
        javaInterface:{
            find: '/api/portalTsLogin/element/getRssData',
            save: '/api/portalTs/rss/save',
            update: '/api/portalTs/rss/update',
            saveOrUpdateItem: '/api/portalTs/rss/saveOrUpdateItem',
            deleteItem: '/api/portalTs/rss/deleteItem',
            orderItem: '/api/portalTs/rss/orderItem',
        }
    }

    onSaveBeforeHandler = (setting={})=>{
        setting.title =  'RSS元素'

    }

    onLoadAfterHandler = (data)=>{
        for(let i in data.showFields){
            if(data.showFields.hasOwnProperty(i)){
                data.showFields[i].name = getLabel(data.showFields[i].name, data.showFields[i].name)
            }
        }
        // for(let i = 0 ;i < data.items.length ; i++){
        //
        //
        //     $.ajax({
        //         url:data.items[i].url,
        //         type:'GET',
        //         dataType:'xml',
        //         success: (data)=>{
        //             console.info(data)
        //         },
        //         error: (data)=>{
        //             console.info(data)
        //         }
        //     })
        // }

    }

    render(){

        return (
            <ContainerModle ecId={`${this && this.props && this.props.ecId || ''}_ContainerModle@i0sfyd`} {...this.props} {...(this.props.location ? this.props.location.query :{})} ContainerViewProxy={MoreContainerView} SettingProxy={SettingProxy} onSaveBeforeHandler={this.onSaveBeforeHandler} onLoadAfterHandler={this.onLoadAfterHandler} AddExtend={AddExtend} SettingExtend={SettingExtend} ContainerViewExtend={ContainerViewExtend}>
            </ContainerModle>
        )
    }
}